package cn.wolfcode.wolf2world.web.controller;

import cn.wolfcode.wolf2world.domain.StrategyTheme;
import cn.wolfcode.wolf2world.query.StrategyThemeQueryObject;
import cn.wolfcode.wolf2world.service.StrategyThemeService;
import cn.wolfcode.wolf2world.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 杨兴健
 * @Date 2020-08-11 19:00
 */
@Controller
@RequestMapping("/strategyTheme")
public class StrategyThemeController {
    @Autowired
    private StrategyThemeService strategyThemeService;

    /**
     * 目的地高级查询
     *
     * @param model
     * @param qo    查询条件
     * @return
     */
    @RequestMapping("/list")
    public String query(Model model, @ModelAttribute("qo") StrategyThemeQueryObject qo) {
        Page<StrategyTheme> page = strategyThemeService.query(qo);
        model.addAttribute("page", page);
        return "strategyTheme/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyTheme strategyTheme) {
        strategyThemeService.saveOrUpdate(strategyTheme);
        return JsonResult.success();
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id) {
        strategyThemeService.delete(id);
        return JsonResult.success();
    }
}
